package com.zingrow.web.report.response;

import java.io.Serializable;

import org.joda.time.DateTime;
import org.joda.time.LocalDate;

public class CountData extends BaseData implements Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = 3854977481453312625L;

    @Override
    public String toString() {
        return "CountData [getTime()=" + getTime() + ", getFirstNum()=" + getFirstNum() + ", getSecondNum()="
                + getSecondNum() + ", getSourceName()=" + getSourceName() + "]";
    }

    @Override
    public int compareTo(BaseData o) {
        if (getTime() != null && o.getTime() != null) {
            LocalDate ld1 = new LocalDate(new DateTime(getTime()));
            LocalDate ld2 = new LocalDate(new DateTime(o.getTime()));
            return ld1.compareTo(ld2);
        }
        return 0;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof CountData && getTime() != null && ((BaseData) obj).getTime() != null) {
            LocalDate ld1 = new LocalDate(new DateTime(getTime()));
            LocalDate ld2 = new LocalDate(new DateTime(((BaseData) obj).getTime()));
            return ld1.equals(ld2);
        }
        return super.equals(obj);
    }
}
